<?php
/* @var $this MenuadminController */
/* @var $model Menuadmin */

$this->breadcrumbs=array(
   'Quản lý menu' => '/index.php/admin/'.$this->id,
	'Cập nhật',
);
?>
<div class="form" id="<?php echo Yii::app()->controller->id . '-' . Yii::app()->controller->action->id?>">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>Yii::app()->controller->id . '_' . Yii::app()->controller->action->id,
   'action' => CController::createUrl('/admin/menu/edit/'.$model->MenuAdminID),
	'enableAjaxValidation'=>false,
   'enableClientValidation'=>true,
   'htmlOptions' => array(
      'enctype' => 'multipart/form-data',
      'class' => 'form-horizontal'
   )
)); ?>

	<p class="note">Những dòng đánh dấu <span class="required">*</span> là bắt buộc.</p>

	<?php echo $form->errorSummary($model,'Kiểm tra lại các giá trị bạn vừa nhập vào'); ?>
   <input name="session_user" type="hidden" value="<?php echo $session_user?>"/>
   <?php echo $form->hiddenField($model,'MenuAdminID')?>
   <input name="action_user" type="hidden" value="" id="action_user" />
   <div class="control-group">
      <?php echo $form->labelEx($model, 'Menu1',array('class' => 'control-label'));?>
      <div class="controls">
         <?php echo $form->dropDownList($model, 'Menu1',$menu_level_1,array('options' =>$attrbutes_level_1));?>
      </div>
   </div>
   <div class="control-group">
      <?php echo $form->labelEx($model, 'Menu2',array('class' => 'control-label'));?>
      <div class="controls">
         <?php echo $form->dropDownList($model, 'Menu2',$menu_level_2,array('options' =>$attrbutes_level_1));?>
      </div>
   </div>
   <div class="control-group">
      <?php echo $form->labelEx($model, 'Menu3',array('class' => 'control-label'));?>
      <div class="controls">
         <?php echo $form->dropDownList($model, 'Menu3',$menu_level_3,array('options' =>$attrbutes_level_3));?>
      </div>
   </div>
   <div class="control-group">
      <?php echo $form->labelEx($model, 'Menu4',array('class' => 'control-label'));?>
      <div class="controls">
         <?php echo $form->textField($model, 'MenuName',array('value' => "",'placeholder' => 'Tên menu','style' => 'width:250px'));?>
      </div>
   </div>
   <div class="control-group">
      <?php echo $form->labelEx($model, 'MenuName',array('class' => 'control-label'));?>
      <div class="controls">
         <?php echo $form->textField($model, 'MenuName',$menu_level_2,array('options' =>$attrbutes_level_1));?>
      </div>
   </div>
   <div class="control-group">
      <?php echo $form->labelEx($model, 'MenuCode',array('class' => 'control-label'));?>
      <div class="controls">
         <?php echo $form->textField($model, 'MenuCode',array('value' => "",'placeholder' => 'Mã menu','style' => 'width:150px'));?>
      </div>
   </div>
   <div class="control-group">
      <?php echo $form->labelEx($model, 'MenuPath',array('class' => 'control-label'));?>
      <div class="controls">
         <?php echo $form->textField($model, 'MenuPath',array('placeholder' => 'Đường dẫn','style' => 'width:350px'));?>
      </div>
   </div>
   <div class="control-group">
      <?php echo $form->labelEx($model, 'MenuImage',array('class' => 'control-label'));?>
      <div class="controls">
         <?php echo $form->fileField($model, 'MenuImage');?>
      </div>
   </div>
   <div class="control-group">
      <?php echo $form->labelEx($model, 'IsHome',array('class' => 'control-label'));?>
      <div class="controls">
          <?php echo $form->checkBox($model, 'IsHome',array('checked'=>'checked'));?>
      </div>
   </div>
   <div class="control-group">
      <?php echo $form->labelEx($model, 'IsActive',array('class' => 'control-label'));?>
      <div class="controls">
         <?php echo $form->checkBox($model, 'IsActive',array('checked'=>'checked'));?>
      </div>
   </div>
   <div class="form-actions">
      <?php echo CHtml::submitButton('Lưu',array('class' => 'btn btn-info'))?>
      <?php echo CHtml::resetButton('Hủy',array('class' => 'btn btn-warning' ,'onclick' => 'window.history.go(-1)'))?>
	</div>
<?php $this->endWidget(); ?>
</div> 
<script>
   $(document).ready(function(){
      
      
      //Load menu level 2 when selected menu level 1
      $("#Menuadmin_Menu1").change(function(){
         var url = '<?php echo CController::createUrl('loadMenu2')?>';
         var menu = $('option:selected',this).attr('menu');
         data = {"menu":menu};
         var succ = function(data){
            $("#Menuadmin_Menu3").html('<option value="0" menu="0">-- Nhóm 3 --</option>');
            $("#Menuadmin_Menu2").html(data);
         };
         handleAjax(url,'POST','',data,succ);
      });
      
      //Load menu level 3 when selected menu level 2
      $("#Menuadmin_Menu2").change(function(){
         var url = '<?php echo CController::createUrl('loadMenu3')?>';
         var menu = $('option:selected',this).attr('menu');
         data = {"menu":menu};
         var succ = function(data){
            $("#Menuadmin_Menu3").html(data);
         };
         handleAjax(url,'POST','',data,succ);
      });
      
   });
</script>


